
from math import sin

def curve(x):
    return 10 * sin(1.0/(x+1))

def chart(env, start_response):
    from whiff.middleware.ofc import OpenFlashChart
    spec = {}
    spec["width"] = spec["height"] = 210
    spec["title"] = {"text": "a curve"}
    data = [ curve(x) for x in range(10) ]
    spec["elements"] = [{"type": "bar", "values": data}]
    barchart = OpenFlashChart.__middleware__(page=spec)
    return barchart(env, start_response)

__wsgi__ = chart
